from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.support import set_cutscene, get_game
from items.map import Map
#from items.keys import Scuba_Suit
#from items.keys import Glow_Stick

class Siren(Room):
    
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
                   
        # add inventory items
#        self.add_item(Map())
        self.add_action(In)
        self.add_action(RunAway)
        self.add_action(Sing)
        
    # return description of room.
    def get_description(self):
        return 'Lo and behold! You have met a siren. Aint she a beauty? Well, now she likes you so much that she offers you a map (We know you were expecting more). The map can guide you to the ship wreckage.'
    
    # return image of room
    def get_image(self):
        return 'siren.jpg'
         

class SirenHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Siren

# define actions for this room

class In(Action):
    def __init__(self):
        Action.__init__(self, "In")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go Deeper"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        game = get_game()
        player = game.get_player()
        if 'map' in player.inventory:
            if 'scuba_suit' in player.inventory:
                return 'deck'
            else:
                set_cutscene("You cannot go deeper without the scuba equipment.")
                return 'siren'
        else:
            return 'siren'
        
       
    def do_action(self,game,room,request):
        game = get_game()
        player = game.get_player()
        if 'map' in player.inventory:
            return set_cutscene("")
        else:
            return set_cutscene("Do you want to get lost and die in the cold depths of the ocean? Try taking the map.")
      
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
class RunAway(Action):
    def __init__(self):
        Action.__init__(self, "RunAway")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Run Away"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'speed_boat'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

class Sing(Action):
    def __init__(self):
        Action.__init__(self, "Sing")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Sing a song"
    
    # return id of room to enter when action is complete
    def do_action(self,game,room,request):
            player = game.get_player()
            if 'map' in player.inventory:
                return set_cutscene('''The siren really loves your song. You are the next Tom Jones!
                <audio autoplay="autoplay">
                <source src="images/un.mp3" type="audio/mp3" />
                Your browser does not support this audio
                </audio>''')
            else:
                set_cutscene('''The siren loves the song! She gives you a map!
                <audio autoplay="autoplay">
                <source src="images/un.mp3" type="audio/mp3" />
                Your browser does not support this audio
                </audio>''')
                player.add_item(Map())
                 
    
    
    